#ifndef _SGCAMIF_H_
#define _SGCAMIF_H_

#ifdef SGCAMIF_EXPORTS
#define INTERFACE_API __declspec(dllexport)
#elif defined(_USRDLL)
#define INTERFACE_API __declspec(dllimport)
#else
#define INTERFACE_API
#endif

#define SG311_CHIP_VERSION_B		(ULONG)('1'<<8|'B')
#define SG311_CHIP_VERSION_C		(ULONG)('1'<<8|'C')
#define SG320_CHIP_VERSION_B		(ULONG)('2'<<8|'B')
#define SG320_CHIP_VERSION_C		(ULONG)('2'<<8|'C')
#define SG320_CHIP_VERSION_D		(ULONG)('2'<<8|'D')
#define SG320_CHIP_VERSION_E		(ULONG)('2'<<8|'E')
#define SG320_CHIP_VERSION_F		(ULONG)('2'<<8|'F')
#define SG330_CHIP_VERSION_A		(ULONG)('3'<<8|'A')
#define EEPROM_VERSION_LENGTH		9
#define READ_BYTES_MAX	20

#define NeedApend4Zeroes(ChipVersion) (ChipVersion == SG311_CHIP_VERSION_B	\
							|| ChipVersion == SG320_CHIP_VERSION_B	\
							|| ChipVersion == SG320_CHIP_VERSION_C	\
							|| ChipVersion == SG320_CHIP_VERSION_D)

enum {
	UVC_STREAM_FrameRate = 0,
	nUVC_AWBMode,
	nIQEnable,
	SensorReadFunc,
	RomCopy,
	EEPROM_Read,
	OTP_Read,
	nVendorDataExistFlag,
	nEECheckSum,
	bSensorIdentified,
	nSENSetStep,
	nSensorConfigureFlagsBackup,
	SensorDeviceIDH,
	SensorDeviceIDL,
	SensorVendorDeviceIDH,
	SensorVendorDeviceIDL,
	bSensorWorkDone,
	SFR_P0,
	SFR_IEN1,
	SFR_IRCON,
	bVendorUVCDataExist,
	nSensorNum,
	nSensorOperationFlags,
	nSensorFeature,
	nSensorHBlankRegs,
	nSensorVBlankRegs,
	nSensorInitRegs,
	pParamSrcM,
	pParamSrcH,
	pParamSrcL,
	FW_ADDR_NUM
};

INTERFACE_API BOOL GetProperty(HANDLE Handle, ULONG ID, ULONG * Value);
INTERFACE_API BOOL SetProperty(HANDLE Handle, ULONG ID, ULONG Value);
INTERFACE_API BOOL GetSGProperty(HANDLE Handle, ULONG ID, ULONG* Value);
INTERFACE_API BOOL SetSGProperty(HANDLE Handle, ULONG ID, ULONG Value);
INTERFACE_API HANDLE SGIF_Open(void);
INTERFACE_API void SGIF_Close(HANDLE Handle);
INTERFACE_API HANDLE SGIF_GetHandle(void *pObject);
INTERFACE_API void SGIF_PutHandle(HANDLE Handle);
INTERFACE_API BYTE SGIF_GetBitMask(HANDLE Handle, ULONG Addr);
INTERFACE_API BYTE SGIF_ReadXRam(HANDLE Handle, ULONG Addr);
INTERFACE_API void SGIF_ReadXRamArray(HANDLE Handle, ULONG Addr, UCHAR *pBuf, int Size);
INTERFACE_API void SGIF_WriteXRam(HANDLE Handle, ULONG Addr, BYTE Value);
INTERFACE_API BYTE SGIF_ReadIRam(HANDLE Handle, ULONG Addr);
INTERFACE_API void SGIF_WriteIRam(HANDLE Handle, ULONG Addr, BYTE Value);
INTERFACE_API BYTE SGIF_ReadSfrRam(HANDLE Handle, ULONG Addr);
INTERFACE_API void SGIF_WriteSfrRam(HANDLE Handle, ULONG Addr, BYTE Value);
INTERFACE_API BYTE SGIF_ReadXVar(HANDLE Handle, ULONG Addr);
INTERFACE_API void SGIF_WriteXVar(HANDLE Handle, ULONG Addr, BYTE Value);
INTERFACE_API BYTE SGIF_ReadIVar(HANDLE Handle, ULONG Addr);
INTERFACE_API void SGIF_WriteIVar(HANDLE Handle, ULONG Addr, BYTE Value);
INTERFACE_API BYTE SGIF_ReadSFR(HANDLE Handle, ULONG Addr);
INTERFACE_API void SGIF_WriteSFR(HANDLE Handle, ULONG Addr, BYTE Value);
INTERFACE_API void SGIF_ReadOTPArray(HANDLE Handle, ULONG Addr, UCHAR *pBuf, int Size);
INTERFACE_API BYTE SGIF_ReadEEByte(HANDLE Handle, ULONG Addr);
INTERFACE_API BOOL SGIF_GetChipVersion(HANDLE Handle, ULONG *pChipVersion);
INTERFACE_API BOOL SGIF_GetChipEepromVersion(HANDLE Handle, char *pEepromVersion, ULONG Length);
INTERFACE_API BOOL SGIF_GetDataEepromVersion(HANDLE Handle, UCHAR *pEEData, char *pEepromVersion, ULONG Length);
INTERFACE_API BOOL SGIF_WriteSensorRegs(HANDLE Handle, const USHORT *pAddr, const USHORT *pVal, int Regs);
INTERFACE_API BOOL SGIF_ReadSensorRegs(HANDLE Handle, const USHORT *pAddr, USHORT *pVal, int Regs);
INTERFACE_API BOOL SGIF_EraseEEProm(HANDLE Handle, BOOL Is16Bit, int eeprom_size, BOOL bZero);
INTERFACE_API BOOL SGIF_ProgramEEProm(HANDLE Handle, const UCHAR *pBuf, int eeprom_size);
INTERFACE_API BOOL SGIF_ReadEEProm(HANDLE Handle, USHORT Addr, UCHAR *buf, int Bytes);
INTERFACE_API ULONG SGIF_GetEEPromDataLength(HANDLE Handle, BYTE *pBuf);

#endif
